package com.kid.keep.mapper;

import com.honeybee.cloud.framework.common.mapper.BaseCovertMapper;
import com.kid.keep.dto.AddChildDTO;
import com.kid.keep.dto.ChildDTO;
import com.kid.keep.dto.UpdateChildDTO;
import com.kid.keep.po.Child;
import com.kid.keep.request.AddChildRequest;
import com.kid.keep.request.UpdateChildRequest;
import com.kid.keep.vo.AddChildVO;
import com.kid.keep.vo.ChildVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.Date;
import java.util.List;

/**
 * @Description 转换mapper
 * @Author JOHN
 * @Create 2020-01-02
 * @Since 1.0.0
 */
@Mapper(componentModel = "spring")
public interface IChildCovertMapper extends BaseCovertMapper {

    /**
     * dto to  po
     *
     * @param addChildDTO
     * @param id
     * @param updateDate
     * @return
     */
    Child toPO(AddChildDTO addChildDTO, Long id, Date updateDate, Integer dataStatus);

    /**
     * dto to  po
     *
     * @param dataStatus
     * @param id
     * @param updateDate
     * @return
     */
    Child toPO(Long id, Long parentId, Integer dataStatus, Date updateDate);

    /**
     * dto to  po
     *
     * @param updateChildDTO
     * @param updateDate
     * @return
     */
    Child toPO(UpdateChildDTO updateChildDTO, Date updateDate);

    /**
     * po to  dto
     *
     * @param child
     * @return
     */
    @Mappings({
            @Mapping(target = "age", source = "birthday", qualifiedByName = "age"),
    })
    ChildDTO toDTO(Child child);

    /**
     * po to  dto
     *
     * @param childList
     * @return
     */
    List<ChildDTO> toDTO(List<Child> childList);

    /**
     * request to dto
     *
     * @param addUserRequest
     * @param parentId
     * @return
     */
    AddChildDTO toDTO(AddChildRequest addUserRequest, Long parentId);

    /**
     * request to dto
     *
     * @param addUserRequest
     * @param id
     * @return
     */
    UpdateChildDTO toDTO(UpdateChildRequest addUserRequest, Long id);

    /**
     * dto to po
     *
     * @param updateChildDTO
     * @return
     */

    Child toDTO(UpdateChildDTO updateChildDTO);

    /**
     * dto to response
     *
     * @param childDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    AddChildVO toVO(ChildDTO childDTO);

    /**
     * dto to  vo
     *
     * @param childDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    ChildVO toChildVO(ChildDTO childDTO);
    /**
     * dto to  vo
     *
     * @param childDTOList
     * @return
     */

    List<ChildVO> toVO(List<ChildDTO> childDTOList);
}
